<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>chunk</title>
</head>

<body>
    <div>打开浏览器控制台查看结果</div>
    <script>
        const chunk = (arr, size) =>
            Array.from({ length: Math.ceil(arr.length / size) }, (v, i) =>
                arr.slice(i * size, i * size + size)
            );
        console.log(chunk([1, 2, 3, 4, 5], 2));
    </script>
</body>

</html>